"""App Engine data model (schema) definition for Purcell Marian (purcellmarian.org) Website."""

# Python imports
import logging
import re

# AppEngine imports
from google.appengine.ext import db
from google.appengine.api import memcache
from google.appengine.ext import search  

class User (db.Model):
    """Entity: User."""
    GoogleUser = db.UserProperty(required=True)
    UserFirstName = db.StringProperty(required=False)
    UserLastName = db.StringProperty(required=False)
    CreateDate = db.DateProperty(auto_now_add=True)
    ModDate = db.DateProperty(auto_now=True)

class Category(db.Model):
    """Entity: Category """
    CategoryName = db.StringProperty(required=True)
    User = db.ReferenceProperty(User)
    Active = db.BooleanProperty(required=True)
    CreateDate = db.DateProperty(auto_now_add=True)
    ModDate = db.DateProperty(auto_now=True)

class Vendor(db.Model):
    """Entity: Vendor """
    VendorName = db.StringProperty(required=True)
    User = db.ReferenceProperty(User)
    Active = db.BooleanProperty(required=True)
    VendorWebUrl = db.StringProperty(required=False)
    CreateDate = db.DateProperty(auto_now_add=True)
    ModDate = db.DateProperty(auto_now=True)

class CreditCard(db.Model):
    """Entity: Credit Card """
    CreditCardName = db.StringProperty(required=True)
    User = db.ReferenceProperty(User)
    Active = db.BooleanProperty(required=True)
    CreateDate = db.DateProperty(auto_now_add=True)
    ModDate = db.DateProperty(auto_now=True)

class ActualExpense(db.Model):
    """Entity: ActualExpense """
    ActualExpenseDate = db.DateProperty(required=True)
    ActualExpenseAmt = db.FloatProperty(required=True)
    User = db.ReferenceProperty(User)
    Vendor = db.ReferenceProperty(Vendor)
    CreditCard = db.ReferenceProperty(CreditCard)
    Category = db.ReferenceProperty(Category)
    CreateDate = db.DateProperty(auto_now_add=True)
    ModDate = db.DateProperty(auto_now=True)


class BudgetExpenseByCategory(db.Model):
    """Entity: Budget Expense By Category """
    User = db.ReferenceProperty(User)
    Year = db.IntegerProperty(required=True)
    Category = db.ReferenceProperty(Category)
    Seq = db.IntegerProperty(required=True)
    JanExp = db.FloatProperty(required=True)
    FebExp = db.FloatProperty(required=True)
    MarExp = db.FloatProperty(required=True)
    AprExp = db.FloatProperty(required=True)
    MayExp = db.FloatProperty(required=True)
    JunExp = db.FloatProperty(required=True)
    JulExp = db.FloatProperty(required=True)
    AugExp = db.FloatProperty(required=True)
    SepExp = db.FloatProperty(required=True)
    OctExp = db.FloatProperty(required=True)
    NovExp = db.FloatProperty(required=True)
    DecExp = db.FloatProperty(required=True)
    Locked = db.BooleanProperty(required=True)
    CreateDate = db.DateProperty(auto_now_add=True)
    ModDate = db.DateProperty(auto_now=True)

class ActualExpenseByCategory(db.Model):
    """Entity: Actual Expense By Category """
    User = db.ReferenceProperty(User)
    Year = db.IntegerProperty(required=True)
    Category = db.ReferenceProperty(Category)
    JanExp = db.FloatProperty(required=True)
    FebExp = db.FloatProperty(required=True)
    MarExp = db.FloatProperty(required=True)
    AprExp = db.FloatProperty(required=True)
    MayExp = db.FloatProperty(required=True)
    JunExp = db.FloatProperty(required=True)
    JulExp = db.FloatProperty(required=True)
    AugExp = db.FloatProperty(required=True)
    SepExp = db.FloatProperty(required=True)
    OctExp = db.FloatProperty(required=True)
    NovExp = db.FloatProperty(required=True)
    DecExp = db.FloatProperty(required=True)
    CreateDate = db.DateProperty(auto_now_add=True)
    ModDate = db.DateProperty(auto_now=True)

class ActualExpenseByVendor(db.Model):
    """Entity: Actual Expense by Vendor """
    User = db.ReferenceProperty(User)
    Year = db.IntegerProperty(required=True)
    Vendor = db.ReferenceProperty(Vendor)
    JanExp = db.FloatProperty(required=True)
    FebExp = db.FloatProperty(required=True)
    MarExp = db.FloatProperty(required=True)
    AprExp = db.FloatProperty(required=True)
    MayExp = db.FloatProperty(required=True)
    JunExp = db.FloatProperty(required=True)
    JulExp = db.FloatProperty(required=True)
    AugExp = db.FloatProperty(required=True)
    SepExp = db.FloatProperty(required=True)
    OctExp = db.FloatProperty(required=True)
    NovExp = db.FloatProperty(required=True)
    DecExp = db.FloatProperty(required=True)
    CreateDate = db.DateProperty(auto_now_add=True)
    ModDate = db.DateProperty(auto_now=True)   

